Free Applicative Functors
نویسندگان
چکیده
Applicative functors [6] are a generalisation of monads. Both allow the expression of effectful computations into an otherwise pure language, like Haskell [5]. Applicative functors are to be preferred to monads when the structure of a computation is fixed a priori. That makes it possible to perform certain kinds of static analysis on applicative values. We define a notion of free applicative functor, prove that it satisfies the appropriate laws, and that the construction is left adjoint to a suitable forgetful functor. We show how free applicative functors can be used to implement embedded DSLs which can be statically analysed.
منابع مشابه
Equational Reasoning with Applicative Functors
In reasoning about effectful computations, it often suffices to focus on the effect-free parts. We present a package for automatically lifting equations to effects modelled by applicative functors. It exploits properties of the concrete functor thanks to a modular classification based on combinators. We formalise the meta theory and demonstrate the usability of our Isabelle/HOL package with two...
متن کاملConstructing Applicative Functors
Applicative functors define an interface to computation that is more general, and correspondingly weaker, than that of monads. First used in parser libraries, they are now seeing a wide range of applications. This paper sets out to explore the space of non-monadic applicative functors useful in programming. We work with a generalization, lax monoidal functors, and consider several methods of co...
متن کاملNotions of Computation as Monoids
There are different notions of computation, the most popular being monads, applicative functors, and arrows. In this article we show that these three notions can be seen as monoids in a monoidal category. We demonstrate that at this level of abstraction one can obtain useful results which can be instantiated to the different notions of computation. In particular, we show how free constructions ...
متن کاملApplicative Lifting
Applicative functors augment computations with effects by lifting function application to types which model the effects [5]. As the structure of the computation cannot depend on the effects, applicative expressions can be analysed statically. This allows us to lift universally quantified equations to the effectful types, as observed by Hinze [3]. Thus, equational reasoning over effectful comput...
متن کاملF-ing applicative functors
Essential to ML-style module systems is the concept of a functor, i.e. a function from modules to modules. Functors are ML’s way of providing generic data structures and reusable program components. Yet, there is a bewildering schism in ML land regarding the actual semantics of functors, familiar to experts under the code words generative vs. applicative. In Standard ML [3], each application of...
متن کامل